from pyecharts.charts import Sunburst
from pyecharts import options as opts

"""
Gallery 使用 pyecharts 1.1.0
参考地址: https://www.echartsjs.com/examples/editor.html?c=sunburst-simple

目前无法实现的功能:

1、
"""

data = [
    opts.SunburstItem(
        name="1",
        value=18,
        children=[
            opts.SunburstItem(
                name="11",
                value=8,
                children=[
                    opts.SunburstItem(name="111", value=2),
                    opts.SunburstItem(
                        name="112",
                        value=2,
                        children=[opts.SunburstItem(name="1121", value=2)],
                    ),
                    opts.SunburstItem(name="113", value=4),
                ],
            ),
            opts.SunburstItem(
                name="12",
                value=10,
                children=[
                    opts.SunburstItem(name="121", value=5),
                    opts.SunburstItem(name="122", value=5),
                ],
            ),
        ],
    ),
    opts.SunburstItem(
        name="2",
        value=3,
        children=[
            opts.SunburstItem(
                name="21",
                value=3,
                children=[
                    opts.SunburstItem(name="211", value=1),
                    opts.SunburstItem(name="212", value=2),
                ],
            )
        ],
    ),
]

sunburst = (
    Sunburst(init_opts=opts.InitOpts(width="1000px", height="600px"))
    .add(series_name="", data_pair=data, radius=[0, "90%"])
    .set_global_opts(title_opts=opts.TitleOpts(title="Sunburst-基本示例"))
    .set_series_opts(label_opts=opts.LabelOpts(formatter="{b}"))
    .render("basic_sunburst.html")
)
